//
//  Emoticon.swift
//  EmoticonKeyBoard
//
//  Created by apple on 15/12/25.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class Emoticon: NSObject {
    
    //分组表情的文件路径id  用来拼接图片路径用
    var id: String?
    
    //用来向服务发送的表情文本
    var chs: String?
    //图片文件名称 本地替换表情文本
    var png: String?
    
    //定义计算型属性 计算图片的路劲
    var imagePath: String? {
        //mainBundle + Emoticons.bundle + id + png
        let path = NSBundle.mainBundle().bundlePath + "/Emoticons.bundle/" + "\(id ?? "")/" + "\(png ?? "")"
        
        return path
    }
    //emoji表情 对应的十六进制的字符串
    var code: String?
    
    //增加emoji表情的计算型属性
    var emojiStr: String? {
        guard let codeStr = code else {
            return nil
        }
        return codeStr.emojiStr()
    }
    
    //增加标记是否是删除按钮的标记
    var isDelete = false
    
    //增加空表情的字段
    var isEmpty = false
    init(dict: [String : String]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    init(isDelete: Bool) {
        self.isDelete = isDelete
        super.init()
    }
    
    init(isEmpty: Bool) {
        self.isEmpty = isEmpty
        super.init()
    }
    
    //过滤无用字段
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {    }
    
    
    //MARK: 对象的描述方法
    override var description: String {
        let keys = ["chs","png","code"]
        return dictionaryWithValuesForKeys(keys).description
    }

}
